<!DOCTYPE html>
<html>

<head>
    <title>编辑资源</title>
</head>

<body>

<div class="page-header">
    <h1>${_resource_name!''}
        <small><i class="ace-icon fa fa-angle-double-right"></i>
            编辑资源
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <form id="common_form" class="form-horizontal" role="form" action="${ctlKey}/update" method="post">
            <div class="col-xs-12 col-sm-12">
                <@form_input l="id" name="id" val=(resource.id)! />
                <@form_input l="名称" name="resourceName" val=(resource.resourceName)! p="名称"/>
                <@form_input l="英文名称" name="resourceEname" val=(resource.resourceEname)! p="英文名称"/>
                <@form_input l="类型" name="type" val=(resource.type)! p="类型: munu或button"/>
                <@form_input l="URI" name="url" val=(resource.url)! p="URI"/>
                <@form_input l="parentId" name="parentId" val=(resource.parentId)! p="parentId"/>
                <@form_input l="权限" name="permission" val=(resource.permission)! p="权限"/>
                <@form_input l="排序" name="sort" val=(resource.sort)! p="排序"/>
                <@form_input l="icon 样式" name="iconCls" val=(resource.iconCls)! p="icon class"/>
                <@form_input l="code" name="code" val=(resource.code)! p="code"/>

                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="ace-icon fa fa-check bigger-110"></i> Submit
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i> Reset
                        </button>
                    </div>
                </div>

            </div>

        </form>
        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div><!-- /.row -->

</body>
<my_script>
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/common/js/jquery.validate.default.js"></script>
    <script src="/common/js/common.form.js"></script>


    <script type="text/javascript">
        function submitHandler(){
            ctlKey = "/admin/resource/edit/${resource.id!}";
            return true;
        }

        var active_class = 'active';
        $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
            var th_checked = this.checked;//checkbox inside "TH" table header

            $(this).closest('table').find('tbody > tr').each(function(){
                var row = this;
                if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
                else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
            });
        });

        //select/deselect a row when the checkbox is checked/unchecked
        $('#simple-table').on('click', 'td input[type=checkbox]' , function(){
            var $row = $(this).closest('tr');
            if(this.checked) {
                $row.addClass(active_class);
                //选中所有子孙
                $("input[id^='"+$(this).attr("id")+"_']").each(function(){
                    if(!this.checked) {
                        $(this).closest('tr').addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
                    }
                });
            }else{
                $row.removeClass(active_class);
                //取消选中所有子孙
                $("input[id^='"+$(this).attr("id")+"_']").each(function(){
                    if(this.checked) {
                        $(this).closest('tr').removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
                    }
                });
            }
        });
        $('#simple-table input[type=checkbox]').each(function(){
            if(this.checked) {
                var $row = $(this).closest('tr');
                $row.addClass(active_class);
            }
        });
    </script>

</my_script>

</html>